#include "cjgpositionmanager.h"

CJgPositionManager::CJgPositionManager() {}

QString CJgPositionManager::getWorkerNum(int vPosNum)
{
    for (CJgPosition * pp : this->mPositions)
    {
        if (pp->miPosNum == vPosNum)
        {
            return pp->miWorkerNum;
        }
    }
    return "";
}

bool CJgPositionManager::getMoreStatus(int vPosNum, int & oStatus, int & oType,
                                       bool & oEnable, bool & oStop, QString & oWorkerNum, QString & oWaitProBox, QString & oInProBox)
{
    for(CJgPosition * pp : this->mPositions)
    {
        if (pp->miPosNum == vPosNum)
        {
            oStatus = pp->miPosStatus;
            oType = pp->miPositionType;
            oEnable = pp->mbEnable;
            //oStop = pp->mSignal.mbStopReceive;
            oWorkerNum = pp->miWorkerNum;
            oWaitProBox = pp->mBoxWaitingForPro;
            oInProBox = pp->mBoxInPro;
            return true;
        }
    }
    return false;
}

int CJgPositionManager::getStatus(int vPosNum)
{
    for (CJgPosition * pp : this->mPositions)
    {
        if (pp->miPosNum == vPosNum)
        {
            return pp->miPosStatus;
        }
    }
    return -1;
}

qlonglong CJgPositionManager::getCurrentProcessID(int vPosNum)
{
    for (CJgPosition * pp : this->mPositions)
    {
        if (pp->miPosNum == vPosNum)
        {
            return pp->miCurProcessID;
        }
    }
    return -1;
}

QStringList CJgPositionManager::getMachineType(int vPosNum)
{
    QStringList rl;
    for (CJgPosition * pp : this->mPositions)
    {
        if (pp->miPosNum == vPosNum)
        {
            for (int i = 0; i < _MAX_POSITION_MACHINE_TYPE_NUM_; i++)
            {
                rl.append(pp->mMachineTypes[i]);
            }
            break;
        }
    }
    return rl;
}

QDateTime CJgPositionManager::getCurProStart(int vPosNum)
{
    QDateTime r;
    //r.setTime_t(0);
    for (CJgPosition * pp : this->mPositions)
    {
        if (pp->miPosNum == vPosNum)
        {
            return pp->mCurProcessStart;
        }
    }
    return r;
}
